"use strict";
const common_vendor = require("../../common/vendor.js");
const common_share = require("../../common/share.js");
const _sfc_main = {
  // 软水推荐方案
  onShareAppMessage() {
    return {
      title: "软水推荐方案",
      imageUrl: "",
      path: "pages/index/index"
    };
  },
  data() {
    return {
      params1: [
        { label: "年耗盐量", value: "126", unit: "kg", key: "annual_salt_consumption" },
        { label: "加盐周期", value: "90.1", unit: "天", key: "salt_addition_interval" },
        { label: "再生周期", value: "10", unit: "天", key: "regeneration_cycle" },
        { label: "建议单次加盐量", value: "40", unit: "kg", key: "resin_amount" }
      ],
      params2: [
        { label: "再生周期制水量", value: "2.5", unit: "吨", key: "regeneration_water_amount" },
        { label: "单次再生耗盐量", value: "4.20", unit: "kg", key: "regeneration_salt_consumption" }
      ],
      currentResult: {
        "id": 4,
        "hardness_range": "0-200",
        "hardness_calc": 150,
        "population": "≤2",
        "participants": 2,
        "range_value": "≤2口",
        "product_series": "黑金系列",
        "product_model": "SSQ5170i",
        "water_habits": 4,
        "resin_amount": "10.0",
        "annual_salt_consumption": 46,
        "salt_addition_interval": "78.9",
        "regeneration_cycle": 15,
        "suggested_salt_addition": 10,
        "regeneration_water_amount": "2.0",
        "regeneration_salt_consumption": "1.9",
        "created_at": "2023-05-25 20:00:50",
        "updated_at": "2023-05-25 20:00:50"
      },
      matchResultList: []
    };
  },
  onLoad(options) {
    this.getMatchResult();
  },
  methods: {
    getMatchResult() {
      console.log(common_share.getMatchResultList());
      this.matchResultList = common_share.getMatchResultList();
      this.currentResult = this.matchResultList[0] || {};
    },
    showOtherSolution() {
      const ops = this.matchResultList.map((e) => {
        return {
          label: e.product_model,
          value: e.product_model
        };
      }).filter((e) => e.value !== this.currentResult.product_model);
      if (!ops.length) {
        return common_vendor.index.showToast({
          title: "没有更多方案了",
          icon: "none"
        });
      }
      this.showAction({ options: ops });
    },
    goToContrast() {
      if (!common_share.getMatchResultList() || !common_share.getMatchResultList().length) {
        return common_vendor.index.showToast({
          title: "暂时没有方案对比",
          icon: "none"
        });
      }
      common_vendor.index.navigateTo({
        url: "/pages/solution-contrast/solution-contrast"
      });
    },
    showAction(item) {
      const { options, key } = item;
      common_vendor.index.showActionSheet({
        itemList: options.map((e) => e.label),
        success: (res) => {
          const model = options[res.tapIndex].value;
          this.currentResult = this.matchResultList.find((e) => e.product_model === model) || {};
        },
        fail: function(res) {
          console.log(res.errMsg);
        },
        complete: () => {
          this.currentActionIndex = null;
        }
      });
    }
  }
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: common_vendor.t($data.currentResult.product_model),
    b: common_vendor.f($data.params1, (item, index, i0) => {
      return {
        a: common_vendor.t(item.label),
        b: common_vendor.t($data.currentResult[item.key] || "-"),
        c: common_vendor.t(item.unit),
        d: index % 2 === 0 ? 1 : "",
        e: index
      };
    }),
    c: common_vendor.f($data.params2, (item, index, i0) => {
      return {
        a: common_vendor.t(item.label),
        b: common_vendor.t(item.value),
        c: common_vendor.t(item.unit),
        d: index % 2 !== 0 ? 1 : "",
        e: index
      };
    }),
    d: $data.matchResultList && $data.matchResultList.length
  }, $data.matchResultList && $data.matchResultList.length ? {
    e: common_vendor.o((...args) => $options.showOtherSolution && $options.showOtherSolution(...args)),
    f: common_vendor.o((...args) => $options.goToContrast && $options.goToContrast(...args))
  } : {});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "C:/Users/karo/Desktop/finale/3.0/clean-water/clean-water/pages/solution/solution.vue"]]);
_sfc_main.__runtimeHooks = 2;
wx.createPage(MiniProgramPage);
